package cn.dglydrpy.study.common;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.DispatcherServlet;

/**
 * 用于验证热部署:
 * 热部署有效时,3方框架jar包的类和当前业务类的类加载器不一样!
 */
@Component
public class Devtools implements InitializingBean {

    private static final Logger log = LoggerFactory.getLogger(Devtools.class);

    @Override
    public void afterPropertiesSet() throws Exception {
        // 框架bean类加载器 AppClassLoader
        log.info("guava-jar classLoader: " + DispatcherServlet.class.getClassLoader().toString());
        // 当前业务类的类加载器  RestartClassLoader
        log.info("Devtools ClassLoader: " + this.getClass().getClassLoader().toString());
    }
}
